package Thuchanh;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Scanner;

public abstract class Nhanvien_class {
	String ten;
	float luong;
	float bacluong;
	String fileName = "Thong tin nhan vien.txt";

	public Nhanvien_class(String ten, float luong, float bacluong) {
		this.ten = ten;
		this.bacluong = bacluong;
		this.luong = luong;
	}

	public void Nhap() {
		Scanner sc = new Scanner(System.in);
		System.out.println("nhap ten:" );
		this.ten = sc.nextLine();
		System.out.println("nhap luong:" );
		this.luong = sc.nextFloat();
		System.out.println("nhap bac luong:");
		this.bacluong = sc.nextFloat();

	}

	abstract public float tinhluong();

	public void Xuat() {
		System.out.println("ten: " + this.ten);
		System.out.println("luong: " + this.luong);
		System.out.println("bac luong " + this.bacluong);
		System.out.println("thuclanh " + this.tinhluong());

	}

	public void ghiflie() throws IOException {
		FileOutputStream fos = new FileOutputStream(fileName);
		PrintWriter pw = new PrintWriter(fos);
		pw.println("ten: " + this.ten);
		pw.println("luong: " + this.luong);
		pw.println("bac luong " + this.bacluong);
		pw.println("thuclanh " + this.tinhluong());

		fos.flush();
		pw.close();
		System.out.println("ghi file " + fileName + " Thanh Cong");

	}

	public void docflie() throws IOException {
		FileReader fr = new FileReader(fileName);
		BufferedReader br = new BufferedReader(fr);
		String line ="";
		while ((line = br.readLine()) != null)
		{
			System.out.println(line);
			
		}
		br.close();fr.close();
		
		/* 
		 * BufferedReader out = new BufferedReader(new FileReader(fileName));
	
		String text = "";
		int n = 0;
		char[] arr = new char[1024];
		n = out.read(arr);
		text = new String();

		System.out.println(text);
		out.close();	 */
		System.out.println("doc file '" + fileName + "' thanh cong");
	}

}
